home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 376 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.5 KB

  1. Path: cs.mu.OZ.AU!bounce-back
  2. From: vandevod@cs.rpi.edu (David Vandevoorde)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Observations on templates
  5. Date: 09 Feb 96 04:07:44 GMT
  6. Organization: RPI Computer Science
  7. Approved: fjh@cs.mu.oz.au
  8. Message-ID: <xso68dhlf6f.fsf@fork.cs.rpi.edu>
  9. References: <u9vilu8zvz.fsf@yorick.cygnus.com> <ADqNY6n4sN@qsar.chem.msu.su>
  10. NNTP-Posting-Host: munta.cs.mu.oz.au
  11. X-Original-Date: 08 Feb 1996 15:45:28 -0500
  12. In-Reply-To: "Eugene Radchenko"'s message of 8 Feb 1996 17:00:57 GMT
  13. X-Newsreader: Gnus v5.1
  14. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  15.     iQBFAgUBMRrIouEDnX0m9pzZAQHjRgF7BcdwQBLhkwFobNwpFJ+w5HRQBQyAHTJT
  16.     ocHe0zPXzCXChHI9PUOYmKj2lxnBdub9
  17.     =TpIX
  18. Originator: fjh@munta.cs.mu.OZ.AU
  19.  
  20. >>>>> "ER" == "Eugene Radchenko" <eugene@qsar.chem.msu.su> writes:
  21. [...]
  22. >>> 3) Clause [temp.arg.explicit] verses 2-3 requires that for explicit arg in
  23. >>> member template to be present it must be qualified by 'template' keyword,
  24. >>> e.g.
  25. >>> X *p; p->template alloc<200>();
  26. >>> But to use operator -> we need X class definition anyway - so we know that
  27. >>> alloc() is a template.
  28.  
  29. >> It is needed in some situations where we do not have the X class definition
  30. >> -- in template definitions, like with typename.
  31.  
  32. ER> And what are we supposed to do with function alloc() if we do not have the
  33. ER> class definition and hence do not know anything about this function?
  34.  
  35. C++ compilers are not trivial things to write and it makes sense to
  36. decompose the compilation process in well-separated ``phases''. One
  37. such phase is lexical analysis (decomposing the source text into
  38. tokens), another is syntactical analysis (also called parsing; classify
  39. the tokens and their relationship) and yet another one is semantic 
  40. analysis (``interpret the classification and relationships determined
  41. during syntactical analysis''). 
  42.  
  43. I may be somwhat innacurate in my descriptions, but feeding back
  44. information from semantic analysis (e.g., ``class X has no member
  45. template alloc'') to syntactic analysis (so that it can find out that
  46. ``X::alloc is a data member, not a member function template'') makes
  47. the process harder. The traditional example, is more along the
  48. lines of:
  49.  
  50.     p->alloc<2>(0);
  51.  
  52. Is this meant to be equivalent to `(p->alloc < 2) > 0' or to the
  53. invocation of a template member function? With the added syntax,
  54. the parser knows without relying on the semantic analysis.
  55.  
  56.     Daveed
  57. ---
  58. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  59.   Contact address: std-c++-request@ncar.ucar.edu.  Moderation policy:
  60.   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
  61.